<%@ page pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上传图片</title>

<link href="${pageContext.request.contextPath}/users/css/dropzone.css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/users/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/users/js/dropzone.min.js"></script>
</head>
<body>
	<center>
   			<form action="${pageContext.request.contextPath}/ModifyUserImg.do" method="post" onsubmit="return close1();">
   				<table id="content">
  						<tr>
  							<td></td>
  							<td><input type = "hidden" name = "userImg"  id = "userImg"></td>
  						</tr>
 				 </table>
 				 <div id = "img" class = "dropzone"></div>
    			<input type = "button" value = "添加附件" onclick="dropz.processQueue()" />
    			<input type = "submit" value = "提交" id="save"/>
  			</form>
  	</center>
    
    <script type="text/javascript">
    	var dropz = new Dropzone("#img",{
    		url: "${pageContext.request.contextPath}/upload.do",
    		addRemoveLinks:true,
    		autoProcessQueue:false,
    		paralleUploads:2,
    		maxFiles:2,
    		init: function(){
    			this.on("removedfile",function(file){
    				console.log("File " +file.name + "removed");
    			});
    			this.on("success", function(file,data) {  
                	console.log(data.path.toString());
                	document.getElementById("userImg").value=data.path.toString();
                	console.log(document.getElementById("userImg").value);
            });
    		},
    	
    	});
  		function close1(){
  		    parent.location.reload(true);
         	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
         	parent.layer.close(index);
  		}
    </script>
    

</body>
</html>